pingip proto point:DWORD
ipfind proc uses ebx edi esi hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
	local @stWsa:WSADATA
	local @ip[15]:BYTE
	local @Server[256]:BYTE
	local _stStartup:STARTUPINFO
	local _stProcInfo:PROCESS_INFORMATION
	LOCAL @dwThreadID
	LOCAL @th:THREADINFO
	.if uMsg==WM_INITDIALOG
		invoke ShowWindow,hwnd,SW_SHOW
		invoke LoadIcon,hModuleHandle,ip
		invoke SendMessage,hwnd,WM_SETICON,ICON_BIG,eax
		invoke GetDlgItem,hwnd,IDC_BTNFIND
		invoke EnableWindow,eax,FALSE
		invoke GetWindowRect,hwnd,addr IpfindRect
		sub IpfindRect.bottom,162
		invoke ResizeWindow,hwnd,addr IpfindRect,FALSE
	.elseif uMsg==WM_COMMAND
		xor eax,eax
		mov eax,wParam
		and eax,0ffffh
		.if eax==IDC_EDTIP
			invoke GetDlgItemText,hwnd,IDC_EDTIP,addr @Server,256
			invoke lstrlen,addr @Server
			mov ebx,eax
			invoke GetDlgItem,hwnd,IDC_BTNFIND
			.if ebx
				invoke EnableWindow,eax,TRUE
			.else
				invoke EnableWindow,eax,FALSE
			.endif
			mov eax,0
			ret
		.elseif eax==IDC_LSTIP
			mov eax,wParam
			shr eax,16
			.if	ax ==	LBN_DBLCLK
				invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_GETCURSEL,NULL,NULL
				mov ecx,eax
				invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_GETTEXT,ecx,addr @ip
				invoke wsprintf,addr @Server,offset szPingCmd,addr @ip
				invoke GetStartupInfo,addr _stStartup
				invoke RtlZeroMemory,addr @th,sizeof @th
				push hwnd
				pop @th.hwnd
				lea eax,_stStartup
				push eax
				pop @th.lpStartup
				lea eax,_stProcInfo
				push eax
				pop @th.lpProcInfo
				lea eax,@Server
				push eax
				pop @th.APP
				invoke CreateThread,NULL,0,offset pingip,addr @th,NULL,addr @dwThreadID
				invoke CloseHandle,eax
			.endif
		.elseif eax==IDC_BTNFIND
			invoke GetDlgItem,hwnd,IDC_BTNFIND
			invoke EnableWindow,eax,FALSE
			invoke WSAStartup,101h,addr @stWsa
			invoke GetDlgItemText,hwnd,IDC_EDTIP,addr @Server,256
			invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_GETCOUNT,0,0
			.if eax
				invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_RESETCONTENT,0,0
				invoke ResizeWindow,hwnd,addr IpfindRect,FALSE
;				invoke GetWindowRect,hwnd,addr @rect
;				mov ebx,@rect.right
;				sub ebx,@rect.left
;				mov eax,@rect.bottom
;				sub eax,@rect.top
;				mov ecx,81
;				@@:
;				dec ecx
;				dec eax
;				dec eax
;				push ecx
;				push eax
;				invoke MoveWindow,hwnd,@rect.left,@rect.top,ebx,eax,TRUE
;				pop eax
;				pop ecx
;				cmp ecx,0
;				jnz @B
			.endif
			invoke gethostbyname,addr @Server
			.if eax
				mov ebx,eax
				assume ebx:ptr   hostent
				mov ebx,[ebx+hostent.h_list]
				.while DWORD ptr [ebx]
					mov ecx,dword ptr [ebx]
					movzx eax,byte ptr [ecx+3]
					push eax
					movzx eax,byte ptr [ecx+2]
					push eax
					movzx eax,byte ptr [ecx+1]
					push eax
					movzx eax,byte ptr [ecx]
					push eax
					lea eax,[szIpFormat]
					push eax
					lea eax,@ip
					push eax
					call wsprintf
					invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_ADDSTRING,NULL,addr @ip
					add ebx,4
				.endw
				invoke SendDlgItemMessage,hwnd,IDC_LSTIP,LB_GETCOUNT,0,0
				.if eax
					invoke ResizeWindow,hwnd,addr IpfindRect,FALSE
;					invoke GetWindowRect,hwnd,addr @rect
;					mov ebx,@rect.right
;					sub ebx,@rect.left
;					mov eax,@rect.bottom
;					sub eax,@rect.top
;					mov ecx,81
;					@@:
;					dec ecx
;					inc eax
;					inc eax
;					push ecx
;					push eax
;					invoke MoveWindow,hwnd,@rect.left,@rect.top,ebx,eax,TRUE
;					pop eax
;					pop ecx
;					cmp ecx,0
;					jnz @B
				.endif
				assume eax:nothing
			.else
				invoke MessageBox,hwnd,addr szErrIpfind,addr szApp,MB_OK or MB_ICONERROR
			.endif
			invoke WSACleanup
			invoke GetDlgItem,hwnd,IDC_BTNFIND
			invoke EnableWindow,eax,TRUE
		.endif
	.elseif uMsg==WM_CLOSE
		invoke ShowWindow,hwnd,SW_HIDE
	.else
		mov eax,FALSE
		ret
	.endif
	mov eax,TRUE
	ret

ipfind endp
pingip proc uses ebx ecx esi edi point:DWORD
	mov ebx,point
	assume ebx:ptr THREADINFO
	invoke CreateProcess,NULL,[ebx].APP,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,[ebx].lpStartup,[ebx].lpProcInfo
	mov ecx,[ebx].lpProcInfo
	assume ecx:ptr PROCESS_INFORMATION
	invoke WaitForSingleObject,[ecx].hProcess,INFINITE
	invoke CloseHandle,[ecx].hThread
	invoke CloseHandle,[ecx].hProcess
	assume ecx:nothing
	assume ebx:nothing
	ret
pingip endp